<?php

namespace addons\xpframework\library\xcore\xcore\utils;


class XcIncludeFileUtils
{
    private static $ROOT_PATH = __DIR__ . "/../../../../../../";
    private static $ADDONS_PATH = "addons/xpframework/";

    /**
     * include文件
        $sr = XcIncludeFileUtils::include_php_file("addons/xpframework/config/xpConfig.php");
     * @return mixed
     */
    public static function include_php_file($filePath)
    {
        return include(static::$ROOT_PATH . $filePath);
    }

    /**
     * include文件(addons目录下)
        $sr = XcIncludeFileUtils::include_php_addons_file("config/xpConfig.php");
     * @return mixed
     */
    public static function include_php_addons_file($filePath)
    {
        return static::include_php_file(static::$ADDONS_PATH . $filePath);
    }

    /**
     * 读取INI
        $ini = XcIncludeFileUtils::parse_ini_file("addons/xpframework/info.ini");
        echo $ini["name"];
     * @return array
     */
    public static function parse_ini_file($filePath)
    {
        return parse_ini_file(static::$ROOT_PATH . $filePath);
    }

    /**
     * 读取INI(addons目录下)
        $ini = XcIncludeFileUtils::parse_ini_file("info.ini");
        echo $ini["name"];
     * @return array
     */
    public static function parse_ini_addons_file($filePath)
    {
        return static::parse_ini_file(static::$ADDONS_PATH . $filePath);
    }
}
